package com.acme.concurrent.factorization;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Gregory Sobko
 */
public class Factorizer {

    public static Map<Integer,Integer> factorize(int number){
        Map<Integer,Integer> result = new HashMap<Integer, Integer>();
        for(Integer i: SieveOfEratosthenes.getPrimeNumbers(number)){
            while(number % i == 0){
                if(result.containsKey(i)){
                    result.put(i, result.get(i) + 1);
                }else{
                    result.put(i, 1);
                }
                number = number / i;
            }
        }
        return result;
    }

}
